package io.spring.start.site.config;

import org.gitlab4j.api.GitLabApi;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import io.spring.start.site.gitlab.GitlabService;

@Configuration
public class GitlabConfiguration {

	@Autowired
	private GitlabProperties gitlabProperties;

	/**
	 * Http 客户端工具
	 *
	 * 如果有些 API 该Jar工具包未提供，可以用此Http客户端操作远程接口，执行命令
	 * @return
	 */
	@Bean
	GitLabApi gitLabApi() {
		GitLabApi gitLabApi = new GitLabApi(gitlabProperties.getUrl(), gitlabProperties.getPersonalAccessToken());
		return gitLabApi;
	}

	@Bean
	GitlabService gitlabService(GitLabApi gitLabApi) {
		GitlabService gitlabService = new GitlabService(gitLabApi);
		return gitlabService;
	}

}
